﻿using System;
using System.Collections.Specialized;
using Kaio.Core.Extension;


namespace MvcForum.Net.Bussiness
{
    public class AccessMask
    {

        private readonly NameValueCollection _values;

        public string this[string key]
        {
            get { return _values != null ? _values[key] : null; }
        }



        public AccessMask(string access)
        {
            _values = !string.IsNullOrWhiteSpace(access) ? access.ToNameValueCollection('|', ':') : null;
        }



        #region Moderator



        #endregion


        #region AttachFiles

        public string AllowFileTypes
        {
            get { return this["AllowFileTypes"]; }
        }


        public int MaxUploadStorage
        {
            get { return Convert.ToInt32(this["MaxUploadStorage"]); }
        }


        public bool AllowDownloadAttach
        {
            get { return Convert.ToBoolean(this["AllowDownloadAttach"]); }
        }


        /*   public int MaxUploadFiles
           {
               get { return Convert.ToInt32(values["MaxUploadFiles"]); }
           }


           public double MaxFileSize
           {
               get { return double.Parse(values["MaxFileSize"]); }
           }
           public double MaxTotalUploadSize
           {
               get
               {
                   return double.Parse(values["MaxTotalUploadSize"]);
               }
           }*/

        #endregion


        #region Post Options


        public bool AllowStickyPosts
        {
            get { return Convert.ToBoolean(this["AllowStickyPosts"]); }
        }


        public bool PostNewTopics
        {
            get { return Convert.ToBoolean(this["PostNewTopics"]); }

        }

        public bool PostReplyToTopics
        {
            get
            {
                return Convert.ToBoolean(this["PostReplyToTopics"]);

            }

        }


        public bool PostNewPolls
        {
            get { return Convert.ToBoolean(this["PostNewPolls"]); }

        }

        public bool PostReplyToPolls
        {
            get
            {
                return Convert.ToBoolean(this["PostReplyToPolls"]);

            }

        }


        public bool VoteWithinPolls
        {
            get
            {
                return Convert.ToBoolean(this["VoteWithinPolls"]);

            }

        }


        public bool PostWithinLockedForums
        {
            get
            {
                return Convert.ToBoolean(this["PostWithinLockedForums"]);
            }

        }

        public bool PostWithinLockedTopics
        {
            get { return Convert.ToBoolean(this["PostWithinLockedTopics"]); }
        }




        #endregion

        #region Edit Options

        public bool EditOwnTopics
        {
            get { return Convert.ToBoolean(this["EditOwnTopics"]); }

        }

        public bool EditOwnPosts
        {
            get { return Convert.ToBoolean(this["EditOwnPosts"]); }

        }



        /* public bool ViewLastEditedByLabel
         {
             get
             {
                 return Convert.ToBoolean(values["ViewLastEditedByLabel"]);
             }

         }*/

        public bool EditLockedTopics
        {
            get { return Convert.ToBoolean(this["EditLockedTopics"]); }
        }


        public bool UpdateLastEditedBy
        {
            get
            {
                return Convert.ToBoolean(this["UpdateLastEditedBy"]);// Convert.ToBoolean(values["UpdateLastEditedBy"]);
            }

        }

        #endregion

        #region Delete Options

        public bool DeleteOwnTopics
        {
            get
            {
                return Convert.ToBoolean(this["DeleteOwnTopics"]);
            }

        }

        public bool DeleteOwnPosts
        {
            get { return Convert.ToBoolean(this["DeleteOwnPosts"]); }

        }


        public bool DeleteLockedPosts
        {
            get
            {
                return Convert.ToBoolean(this["DeleteLockedPosts"]);

            }

        }

        #endregion


        #region Topics & Forum options

        public bool AllowReadForums
        {

            get
            {
                return Convert.ToBoolean(this["AllowReadForums"]);
            }

        }

        public bool AllowReadTopics
        {

            get { return Convert.ToBoolean(this["AllowReadTopics"]); }

        }


        public bool SendTopicsViaEmail
        {

            get { return Convert.ToBoolean(this["SendTopicsViaEmail"]); }

        }



        #endregion


        #region Subcribe Options

        public bool SubscribeToForums
        {

            get { return Convert.ToBoolean(this["SubscribeToForums"]); }

        }

        public bool SubscribeToTopics
        {

            get { return Convert.ToBoolean(this["SubscribeToTopics"]); }

        }


        #endregion


        #region Moderate Options


        public bool AlwaysPostAprroved
        {
            get
            {
                return Convert.ToBoolean(this["AlwaysPostAprroved"]);

            }


        }

        public bool QueueEdited
        {
            get { return Convert.ToBoolean(this["QueueEdited"]); }

        }

        public bool SendPostApprovedEmail
        {
            get { return Convert.ToBoolean(this["SendPostApprovedEmail"]); }
        }

        public bool AllowPostReports
        {
            get { return Convert.ToBoolean(this["AllowPostReports"]); }
        }


        #endregion

        
        #region Search Options

        public bool AllowSearch
        {
            get { return Convert.ToBoolean(this["AllowSearch"]); }
        }

        public int MaxSearchResults
        {
            get { return Convert.ToInt32(this["MaxSearchResults"]); }

        }

        public int SearchResultsPerPage
        {
            get
            {
                return Convert.ToInt32(this["SearchResultsPerPage"]);

            }

        }


        #endregion


        #region Email Options



        public bool AllowSendEmail
        {
            get
            {

                return Convert.ToBoolean(this["AllowSendEmail"]);

            }

        }

        public int MaxEmailRecipients
        {
            get { return Convert.ToInt32(this["MaxEmailRecipients"]); }

        }



        #endregion
    }
}
